package com.baomidou.kisso.service.ym.impl;
import com.baomidou.kisso.SSOHelper;
import com.baomidou.kisso.common.http.HttpHelper;
import com.baomidou.kisso.common.http.HttpResult;
import com.baomidou.kisso.common.util.MsConfig;
import com.baomidou.kisso.dto.Result;
import com.baomidou.kisso.dto.ResultGenerator;
import com.baomidou.kisso.dto.SSOAccount;
import com.baomidou.kisso.security.token.SSOToken;
import com.baomidou.kisso.service.ym.AccountService;
import com.baomidou.kisso.service.ym.CookieService;
import com.baomidou.kisso.service.ym.TokenService;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Service
public class CookieServiceImpl implements CookieService {
    public static final Logger logger = LoggerFactory.getLogger(CookieServiceImpl.class);

    @Override
    public SSOAccount getCookieAttr(HttpServletRequest request) {
        SSOToken getToken = SSOHelper.getSSOToken(request);
        SSOAccount ssoAccount = new SSOAccount();
        ssoAccount.setAccount(getToken.getAccount());
        ssoAccount.setAccountUuid(getToken.getPassword());
        ssoAccount.setRealName(getToken.getRealName());
        if(getToken==null){
            logger.info("cookie信息为空");
            return null;
        }
        return ssoAccount;
    }
}
